home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / c7105.zip / REPORT.TPX < prev    next >
Text File  |  1994-03-02  |  14KB  |  283 lines

  1. #!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
  2. #!│                               Report.TPX               │Version: 3007.105│
  3. #!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
  4. #!│Structure             Type       Description                              │
  5. #!│────────────────────  ─────────  ─────────────────────────────────────────│
  6. #!│Report                PROCEDURE  Print a report from a file               │
  7. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  8. #!│Version   Comments                                                        │
  9. #!│────────  ────────────────────────────────────────────────────────────────│
  10. #!│3007.000  Release of CDD3 version 3007 templates                          │
  11. #!│3007.103  Repaired Report Procedure                                       │
  12. #!│3007.105  Repaired Report Procedure                                       │
  13. #!└──────────────────────────────────────────────────────────────────────────┘
  14. #!
  15. #PROCEDURE(Report,'Print a Report'),REPORT,SCREEN
  16. #!
  17. #!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
  18. #!│                                 Report                 │Version: 3007.105│
  19. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  20. #!│This procedure template is designed to print most reports an application  │
  21. #!│may require.  Secondary file relationships (1:MANY) are handled by the    │
  22. #!│%RptGetRelatedRecords #GROUP code, which recurses through as many levels  │
  23. #!│of 1:MANY relationships as are defined in the File Schematic, starting    │
  24. #!│with the Primary file, going down the chain of Secondary files beginning  │
  25. #!│with the first Child file of the Primary.  Any other Child files of the   │
  26. #!│Primary file begin a second 1:MANY file chain -- this is not supported.   │
  27. #!│                                                                          │
  28. #!│The MANY:1 (lookup) relationships go multiple levels below the first file │
  29. #!│related to, for every 1:MANY (Parent-Child) relationship at each level.   │
  30. #!│A lookup file may generate a second related lookup.                       │
  31. #!│                                                                          │
  32. #!│This File Schematic is directly supported:                                │
  33. #!│   Primary                                                                │
  34. #!│    └──Secondary (Lookup MANY:1 from Primary)                            │
  35. #!│    │  └──Secondary (Lookup File from Lookup File)                       │
  36. #!│    └──Secondary (Lookup MANY:1 from Primary)                            │
  37. #!│    └─Secondary (Child File of Primary)                                 │
  38. #!│       └──Secondary (Lookup MANY:1 from Secondary Child)                 │
  39. #!│       └──Secondary (Lookup MANY:1 from Secondary Child)                 │
  40. #!│       │  └──Secondary (Lookup File from Lookup File)                    │
  41. #!│       └─Secondary (Child File of Secondary Child)                      │
  42. #!│          └──Secondary (Lookup MANY:1 from Secondary Child)              │
  43. #!│                                                                          │
  44. #!│This File Schematic is NOT directly supported:                            │
  45. #!│   Primary                                                                │
  46. #!│    └──Secondary (Lookup File from Primary)                              │
  47. #!│    │  └─Secondary (Child of Lookup File) -- NO Children of Lookups     │
  48. #!│    └─Secondary (Child File of Primary)                                 │
  49. #!│    │  └──Secondary (Lookup File from Secondary Child)                   │
  50. #!│    └─Secondary (Another Child File of Primary) -- NO 2nd Child chains  │
  51. #!│                                                                          │
  52. #!│Formula Classes supported are:                                            │
  53. #!│  The prefix of a Parent or Child file with :FILTER appended (Pre:FILTER).│
  54. #!│    Creates a record filter to skip records in which the filter           │
  55. #!│    expression does not evaluate as true, just after the file's record    │
  56. #!│    is read.                                                              │
  57. #!│  The name of a Parent or Child file (not a Lookup file).                 │
  58. #!│    Calculates the formula after each read from the file -- this is       │
  59. #!│    immediately after any Pre:FILTER is evaluated.                        │
  60. #!│  No class --                                                             │
  61. #!│    Calculates the formula every time a record is read from any file.     │
  62. #!│                                                                          │
  63. #!│Multi-Up labels are supported -- they must be in the Body Detail band.    │
  64. #!│Multiple Group Breaks are supported on every (Primary or Child Secondary  │
  65. #!│file not on Lookups.                                                      │
  66. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  67. #!│Version   Comments                                                        │
  68. #!│────────  ────────────────────────────────────────────────────────────────│
  69. #!│3007.000  Release of CDD3 version 3007 templates                          │
  70. #!│3007.103  Moved INSERT to SaveFooterFields to after record validation code│
  71. #!│3007.105  Moved code for Progress Screen to directly after opening of     │
  72. #!│          report, to allow proper display of value during all portions    │
  73. #!│          of report printing.                                             │
  74. #!└──────────────────────────────────────────────────────────────────────────┘
  75. #!
  76. #PROTOTYPE('')
  77. #DISPLAY(' ')
  78. #PROMPT('Enable ESC Key Abort',CHECK),%EscapeAbort
  79. #PROMPT('Show Report Progress',CHECK),%ProgressScreen
  80. #PROMPT('CLEAR Record &First',CHECK),%ClearRecord
  81. #PROMPT('Primary File &Access',OPTION),%AccessMethod
  82. #PROMPT('Keyed Order',RADIO)
  83. #PROMPT('Record Order',RADIO)
  84. #PROMPT('Range &Limit Field',COMPONENT),%KeyComponent
  85. #PROMPT('Range &Value Field',FIELD),%ScopeValue
  86. #PROMPT('Red&irect Procedure',PROCEDURE),%RedirectProc
  87. #PROMPT('View Procedure',PROCEDURE),%ViewProc
  88. #INSERT(%RptSetFlags)
  89. #INSERT(%ReportErrorCheck)
  90. #INSERT(%StandardHeader)
  91. #IF(%RedirectProc AND %ViewProc)
  92.   #MAP('TEMPFILE.INC')
  93. #ENDIF
  94.  
  95. %Procedure       PROCEDURE
  96.  
  97. #INSERT(%FileControl)
  98. %LocalData
  99.  
  100. #INSERT(%ReportDataDeclares)                    #!Internal data declarations
  101.   #IF(%ProgressScreen)
  102.  
  103. %ScreenStructure
  104.   #ENDIF
  105.  
  106. %ReportStructure
  107.  
  108. #EMBED('Data Section')
  109.  
  110.   CODE
  111.   #EMBED('Setup Procedure')
  112.   #INSERT(%RptRedirectGroup)                    #!Printer Redirection handling
  113.   #INSERT(%FileControl)
  114.   OPEN(%Report)                                 #<!Prepare to print report
  115.   #IF(%ProgressScreen)
  116.   OPEN(%Screen)
  117.   #ENDIF
  118.   #EMBED('After Report OPEN before Title page')
  119.   #SET(%CodePosition,'SETUP')                   #!Class = SETUP report
  120.   #INSERT(%ReportFormulas)                      #!Generate formulas
  121.   #IF(%ReportTitle)                             #!Print Title Page
  122.   PRINT(%ReportPre:%ReportTitle)                #<!Print Title Page
  123.     #IF(%ProgressScreen)
  124.   DISPLAY                                       #<!Display report progress
  125.     #ENDIF
  126.   #ENDIF
  127.   #IF(%ClearRecord)
  128.     #FIX(%File,%Primary)
  129.   CLEAR(%FilePre:Record)                       #<!Clear record buffer
  130.   #ENDIF
  131.   #IF(%AccessMethod = 'Record Order')           #!Determine primary file order
  132.   SET(%Primary)                                #<!Top of file, record order
  133.   #ELSIF(%SelectorAccess)
  134.     #FIX(%File,%Primary)
  135.     #FIX(%Key,%PrimaryKey)
  136.     #IF(%KeyIndex = 'INDEX')
  137.       #IF(%SharedFiles)
  138.   LOCK(%Primary,1)                             #<!Exclusive access for build
  139.   IF DiskError('Cannot Lock %Primary') THEN RETURN. #<!Check for lock error
  140.       #ENDIF
  141.   BUILD(%PrimaryKey)                           #<!Build the index first
  142.       #IF(%SharedFiles)
  143.   UNLOCK(%Primary)                             #<!Unlock locked file
  144.       #ENDIF
  145.     #ENDIF
  146.   %KeyComponent = %ScopeValue
  147.   #EMBED('Before Initial SET()')
  148.   SET(%PrimaryKey,%PrimaryKey)                 #<!Beginning of selected records
  149.   #ELSE
  150.     #FIX(%File,%Primary)
  151.     #FIX(%Key,%PrimaryKey)
  152.     #IF(%KeyIndex = 'INDEX')
  153.       #IF(%SharedFiles)
  154.   LOCK(%Primary,1)                             #<!Exclusive access for build
  155.   IF DiskError('Cannot Lock %Primary ') THEN RETURN. #<!Check for lock error
  156.       #ENDIF
  157.   BUILD(%PrimaryKey)                           #<!Built the index first
  158.       #IF(%SharedFiles)
  159.   UNLOCK(%Primary)                             #<!Unlock locked file
  160.       #ENDIF
  161.     #ENDIF
  162.   #EMBED('Before Initial SET()')
  163.   SET(%PrimaryKey)                             #<!Top of file, keyed order
  164.   #ENDIF
  165.   #FIX(%File,%Primary)
  166.   %FilePre::PRINTED = 0                        #<!Set records printed flag
  167.   #EMBED('Before primary LOOP after SET')
  168.   LOOP                                         #<!Primary file process loop
  169.     #EMBED('Top of primary LOOP')
  170.     NEXT(%Primary)                             #<!Get each %Primary record
  171.     IF ERRORCODE() THEN ErrEndFileFlag# = 1 ELSE ErrEndFileFlag# = 0. #<!Flag EOF
  172.     #EMBED('In primary LOOP immediately after NEXT')
  173.   #IF(INSTRING(%Primary,%BreakFilesQueue,1,1))  #!Check for group breaks
  174.     #SET(%CurrentFile,%Primary)
  175.     #INSERT(%GroupBreakNumber)
  176.     #FIX(%File,%Primary)
  177.     #SET(%CodePosition,(%FilePre&':FILTER'))
  178.     #INSERT(%RptRecordFilter)                   #!Generate record filter
  179.     #EMBED('In primary LOOP after Record Filter before Lookups')
  180.     #SET(%GetLookupFrom,%Primary)
  181.     #INSERT(%RptGetLookupRecords)               #!Get all Lookup records
  182.     #SET(%CodePosition,%Primary)                #!Class = primary file
  183.     #INSERT(%ReportFormulas)                    #!Generate formulas
  184.     #INSERT(%PrimaryGroupBreak)
  185.   #ELSE                                         #!No group break on this file
  186.     #IF(%SelectorAccess)                        #!If record selector
  187.     IF %KeyComponent <> %ScopeValue |          #<!Past selected records?
  188.        OR ErrEndFileFlag#                      #<!End of file? Terminate report
  189.       BREAK
  190.     END
  191.       #FIX(%File,%Primary)
  192.       #SET(%CodePosition,(%FilePre&':FILTER'))
  193.     #INSERT(%RptRecordFilter)                   #!Generate record filter
  194.     #EMBED('In primary LOOP after Record Filter before Lookups')
  195.       #SET(%GetLookupFrom,%Primary)
  196.     #INSERT(%RptGetLookupRecords)               #!Get all Lookup records
  197.       #SET(%CodePosition,%Primary)              #!Class = primary file
  198.     #INSERT(%ReportFormulas)                    #!Generate formulas
  199.     #ELSE                                       #!No record selector
  200.     IF ErrEndFileFlag# THEN BREAK.             #<!End of file? Terminate report
  201.       #FIX(%File,%Primary)
  202.       #SET(%CodePosition,(%FilePre&':FILTER'))
  203.     #INSERT(%RptRecordFilter)                   #!Generate record filter
  204.     #EMBED('In primary LOOP after Record Filter before Lookups')
  205.       #SET(%GetLookupFrom,%Primary)
  206.     #INSERT(%RptGetLookupRecords)               #!Get all Lookup records
  207.       #SET(%CodePosition,%Primary)              #!Class = primary file
  208.     #INSERT(%ReportFormulas)                    #!Generate formulas
  209.     #ENDIF
  210.     #IF(%ReportSaveExist)
  211.       #SET(%SaveFile,%Primary)                  #!Check for footer save fields
  212.     #INSERT(%SaveFooterFields)
  213.     #ENDIF
  214.   #ENDIF
  215.     #EMBED('In primary LOOP after Lookups')
  216.   #IF(%SecondaryExist)                          #!If there are secondary files
  217.     #SET(%Parent,%Primary)
  218.     #INSERT(%RptGetRelatedRecords)
  219.   #ENDIF
  220.   #IF(%DetailPrinted <> 'PRINTED')              #!If detail print not generated
  221.     #INSERT(%PrintDetail)
  222.     #INSERT(%RptAbortKey)                       #!Insert ESC key abort loop
  223.   #ENDIF
  224.   END                                          #<!End %Primary file loop
  225.   #IF(%DetailPrinted <> 'PRINTED')              #!If detail print not generated
  226.     #IF(%ReportLabel)
  227.   #INSERT(%PrintDanglingLabels)
  228.     #ENDIF
  229.   #ENDIF
  230.   #EMBED('After primary LOOP before grand totals & final page')
  231.   #IF(%ReportGrand)                             #!Print grand totals
  232.   PRINT(%ReportPre:%ReportGrand)               #<!Print grand totals
  233.     #IF(%ProgressScreen)
  234.   DISPLAY                                      #<!Display report progress
  235.     #ENDIF
  236.   #ENDIF
  237.   #IF(%ReportFinal)                             #!Print final page
  238.   PRINT(%ReportPre:%ReportFinal)               #<!Print final page
  239.     #IF(%ProgressScreen)
  240.   DISPLAY                                      #<!Display report progress
  241.     #ENDIF
  242.   #ENDIF
  243.   CLOSE(%Report)                               #<!Close report
  244.   #SET(%ResetTotalType,'NONE')                  #!Reset report totals
  245.   #INSERT(%ResetTotals)
  246.   #IF(%ProgressScreen)
  247.   CLOSE(%Screen)                               #<!Close report progress screen
  248.   #ENDIF
  249.   #IF(%ViewProc)
  250.   %ViewProc                                    #<!Call View Procedure
  251.     #IF(%RedirectProc)
  252.   IF TempFile                                    #<!Check for temporary file
  253.     IF RemoveFile(TempFile)                      #<! and delete it
  254.       #INSERT(%DelTempFileErrMsg)
  255.     END
  256.   END
  257.     #ENDIF
  258.   #ENDIF
  259.   DO ProcedureReturn
  260. !─────────────────────────────────────────────────────────────────────────────
  261. ProcedureReturn ROUTINE
  262.   #EMBED('Before Closing Files')
  263.   #INSERT(%FileControl)
  264.   DO EndOfProcedureEmbed
  265.   RETURN
  266. !─────────────────────────────────────────────────────────────────────────────
  267. EndOfProcedureEmbed ROUTINE
  268. #EMBED('End of Procedure')
  269. #EMBED('Custom Routines')
  270.  
  271.   #IF(%ReportGroupExist)
  272. #INSERT(%BreakFooterRoutines)                   #!Print Group Break footers
  273. #INSERT(%BreakHeaderRoutines)                   #!Print Group Break headers
  274.   #ENDIF
  275. #INSERT(%RptTotalRoutines)                      #!Total tallys and resets
  276.   #IF(%ReportSaveExist)
  277.     #SET(%TempQueue,%SaveFilesQueue)
  278. #INSERT(%SaveFooterRoutine)                     #!Footer save field saves
  279. #INSERT(%PrintFooterRoutine)                    #!Footer save field saves
  280. #INSERT(%RestoreFooterRoutine)                  #!Footer save field saves
  281.   #ENDIF
  282. #CHAIN('Print.tpx')
  283.